{assign var='header' value='header2'}
{include file="top.html"}
<link rel="stylesheet" href="/style/mobile/css/order.css">
<div id="content" class="container main">
    <form action="/order/done" method="post" target="iframeNews">
        <div class="tips-m">
            <ul class="m-cart-address">
                {foreach from=$data.addressList item=m key=key}
                <li id="address-{$m.id}" {if $smarty.session.order_address_id eq $m.id} class="on"{/if}>
                <b>{if $smarty.session.order_address_id eq $m.id}寄送至：{/if}</b>
                <label>
                    <input type="radio" name="address_id" value="{$m.id}" onchange="changeAddress('{$m.id}')" {if $smarty.session.order_address_id eq $m.id} checked{/if} />
                    {$m.area} {$m.address}（{$m.name} 收）<span>{$m.mobile}</span>
                </label>
                <span style="display: none;"><a href="{url('/member/address/'|cat:$m.id|cat:'?back=/order/buy/'|cat:$type|cat:'/'|cat:$id)}" class="ui-right address-edit"{if $smarty.session.order_address_id eq $m.id} style="display:block"{/if}>修改本地址</a></span>
                </li>
                {/foreach}
            </ul>
        </div>
        <div class="title-o">订单商品</div>
        <div class="pay-list">
            <ul>
                {foreach from=$data.cart item=m}
                <li class="ui-clr">
                    <span class="name"><a target="_blank" href="{if $smarty.session.extension_code neq 3}{url('/auction/view/'|cat:$m.goods_id)}{else}{url('/yunbuy/detail/'|cat:$db_info.buy_id)}{/if}">{$m.goods_name}</a></span>
                    <span class="num"><b class="color01">{if $smarty.session.extension_code neq 3}{$m.goods_price|price_format}{else}{$m.market_price|price_format}{/if}</b></span>
                </li>
                {/foreach}
            </ul>
        </div>

        <div class="title-o">订单备注</div>
        <div class="order-area">
            <textarea name="goods_info" style="width:100%;height:60px;border:0;padding:5px;">{$data.tips}</textarea>
        </div>

        {if $smarty.session.extension_code neq 3}
        <div class="m-cart-order-options">
            <div class="option">
                <label class="w-checkbox">
                    <input type="checkbox" name="integral" id="integral" value="1" onchange="changeAmount({ integral:this.checked==true?1:0 })" />
                    <span>使用{$L.unit_pay_points}抵消部分余额，{$L.unit_pay_points}余额：<b class="color01">{$member.pay_points}</b> ，此订单可使用：<b class="color01">{$data.pay_points}</b> {$L.unit_pay_points}</span>
                </label>
            </div>
            <div class="option">
                <label class="w-checkbox">
                    <input type="checkbox" name="surplus" id="surplus" value="1" onchange="changeAmount({ surplus:this.checked==true?1:0 })" />
                    <span>使用账户余额支付，帐户余额：<b class="color01">{$member.user_money|price_format}</b></span>
                </label>
            </div>
        </div>
        {/if}

        {if $smarty.session.extension_code neq 3}
        <div class="m-cart-order-pay f-clear" style="min-height: 120px;">
            {include file="order/total.html"}
        </div>
        {/if}

        <div class="order-submit">
            <button class="ap-button" type="submit">{if $smarty.session.extension_code neq 3}确认支付{else}确认领取{/if}</button>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        {if $total.integral > 0}
        $('#integral').click();
        {/if}
        {if $total.surplus > 0}
        $('#surplus').click();
        {/if}
    })
    function changeAddress(id){
        $('.m-cart-address li').removeClass('on').find('b').html('');
        $('#address-'+id).addClass('on').find('b').html('寄送至：');

        var D = { address_id:id };
        $.post("/order/updateAddress", D,
            function(data){
                //location.reload();
            }
        );
    }
    function changeAmount(D){
        $.post("/order/updateAmount", D,
            function(data){
                if(data){
                    $('.m-cart-order-pay').html(data);
                }
            }
        );
    }
</script>
<iframe name="iframeNews" style="display:none;"></iframe>
</body>
</html>